package se.nikmel.AnDisper;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.Window;

/* 
 * Kolla life-cycle här:
 * http://developer.android.com/reference/android/app/Activity.html
 * 
 */
public class AnDisperActivity extends Activity {
	// Constants
	@SuppressWarnings("unused")
	private static final String TAG = "AnDisperActivity"; // Logging tag
	public static final String VERSION = "0.5.3";

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);		
		this.setContentView(R.layout.scr_splash);
		//this.setTitle("Starting up AnDisper");
	}

	@Override
	protected void onResume() {
		super.onResume();
		_StartMainActivityTask tskStart = new _StartMainActivityTask();
		tskStart.execute((Void) null);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		menu.add("AnDisper ver. " + VERSION);	

		return super.onCreateOptionsMenu(menu);
	}

	private class _StartMainActivityTask extends AsyncTask<Void, Void, Void> {

		@Override
		protected Void doInBackground(Void... arg0) {
			Intent intLoadMainApp = new Intent(getApplicationContext(),
					MainActivity.class);
			startActivity(intLoadMainApp);
			return null;
		}

		@Override
		protected void onCancelled() {
			super.onCancelled();
			// m_uiProgress.dismiss();
		}

		@Override
		protected void onPostExecute(Void result) {
			super.onPostExecute(result);
			setProgressBarIndeterminateVisibility(false);
		}

		@Override
		protected void onPreExecute() {
			setProgressBarIndeterminate(true);
			setProgressBarIndeterminateVisibility(true);
		}

	}
}
